package com.hudongwx.shansun.define;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.hudongwx.shansun.R;

/**
 * Created by hudongwx on 16-11-1.
 */
public class MyPopuWinDown extends PopupWindow {
    private TextView tv1, tv2, tv3;
    private LinearLayout ll;
    private GridView gridView;
    private View mVie;
    private Button btn1, btn2;

    public MyPopuWinDown(Context context, ItemOnClick itemOnClick) {
        super(context);
        if (mVie==null){
           LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           mVie = inflater.inflate(R.layout.buy_screen_item, null);
           ll = (LinearLayout) mVie.findViewById(R.id.buy_screen_ll_1);
           gridView = (GridView) mVie.findViewById(R.id.buy_screen_gv);
           tv1 = (TextView) mVie.findViewById(R.id.buy_screen_tv_1);
           tv2 = (TextView) mVie.findViewById(R.id.buy_screen_tv_2);
           tv3 = (TextView) mVie.findViewById(R.id.buy_screen_tv_3);
           btn1 = (Button) mVie.findViewById(R.id.buy_screen_btn_1);
           btn2 = (Button) mVie.findViewById(R.id.buy_screen_btn_2);
           tv1.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                   dismiss();
               }
           });
           itemOnClick.gird(gridView);
           itemOnClick.line(ll);
           itemOnClick.tv2(tv2);
           itemOnClick.tv3(tv3);
           itemOnClick.btn1(btn1);
           itemOnClick.btn2(btn2);

           this.setContentView(mVie);
           //设置PopupWindow弹出窗体的宽
           this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
           //设置PopupWindow弹出窗体的高
           this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
           //设置PopupWindow弹出窗体可点击
           this.setFocusable(true);
           //设置SelectPicPopupWindow弹出窗体动画效果
           this.setAnimationStyle(R.style.Animation);
           //实例化一个ColorDrawable颜色为半透明
           ColorDrawable dw = new ColorDrawable(0xb0000000);
           //设置SelectPicPopupWindow弹出窗体的背景
           this.setBackgroundDrawable(dw);
       }



    }

    public interface ItemOnClick {
        void tv2(TextView tv2);

        void tv3(TextView tv3);

        void line(LinearLayout linearLayout);

        void gird(GridView gridView);

        void btn1(Button button);

        void btn2(Button button);
    }
}
